//
//  PayTransactionManager.swift
//  iModern
//
//  Created by Ralf on 6/9/15.
//  Copyright (c) 2015 com.starlooking. All rights reserved.
//

import UIKit

class PayTransactionManager: Services
{
    //同意下单接口
    func createWechatPayTransactionRecord(numberOfOrder: String, tip: Double) -> ResultSet
    {
        let params = NSMutableDictionary()
        params.setValue(getSessionID(), forKey: "sessionID")
        params.setValue(numberOfOrder, forKey: "appointmentID")
        params.setValue(tip, forKey: "tip")
        return request("TransactionRecord/createTransactionRecord", params: params as [NSObject:AnyObject])
    }
    //修改订单状态
    func updateOrderState(numberOfOrder: String) -> ResultSet
    {
        let params = NSMutableDictionary()

        params.setValue(numberOfOrder, forKey: "numberOfOrder")
        return request("TransactionRecord/pendingTransactionRecord", params: params as [NSObject:AnyObject])
    }
    //根据订单号查询订单状态
    func queryTransactionRecord(appointmentID: String) -> ResultSet
    {
        let params = NSMutableDictionary()
        params.setValue(getSessionID(), forKey: "sessionID")
        params.setValue(appointmentID, forKey: "appointmentID")
        return request("TransactionRecord/queryTransactionRecord", params: params as [NSObject:AnyObject])
    }
    //根据appointmentID查询订单状态
    func queryLastTransactionRecord(appointmentID: String) -> ResultSet
    {
        let params = NSMutableDictionary()
        params.setValue(getSessionID(), forKey: "sessionID")
        params.setValue(appointmentID, forKey: "appointmentID")
        return request("TransactionRecord/queryLastTransactionRecord", params: params as [NSObject:AnyObject])
    }

    func cancelTransactionRecord(numberOfOrder: String) -> ResultSet
    {
        let params = NSMutableDictionary()
        params.setValue(getSessionID(), forKey: "sessionID")
        params.setValue(numberOfOrder, forKey: "numberOfOrder")
        return request("TransactionRecord/cancelTransactionRecord", params: params as [NSObject:AnyObject])
    }
    //确认预约
    func confirmTransactionRecord(appointmentID: Int) -> ResultSet
    {
        let params = NSMutableDictionary()
        params.setValue(getSessionID(), forKey: "sessionID")
        params.setValue(appointmentID, forKey: "appointmentID")
        return request("article/confirmAppointment", params: params as [NSObject:AnyObject])
    }
    //取消预约
    func cancelAppointment(appointmentID: Int) -> ResultSet
    {
        let params = NSMutableDictionary()
        params.setValue(getSessionID(), forKey: "sessionID")
        params.setValue(appointmentID, forKey: "appointmentID")
        return request("article/cancelAppointment", params: params as [NSObject:AnyObject])
    }
    //直接完单，不付款
    func completeAppointment(appointmentID: Int) -> ResultSet
    {
        let params = NSMutableDictionary()
        params.setValue(getSessionID(), forKey: "sessionID")
        params.setValue(appointmentID, forKey: "appointmentID")
        return request("article/completeAppointment", params: params as [NSObject:AnyObject])
    }

}
